package com.ruoyi.supervise.service.impl;

import java.util.Date;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.ruoyi.common.annotation.DataSource;
import com.ruoyi.common.enums.DataSourceType;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.supervise.domain.ProjectArchives;
import com.ruoyi.supervise.mapper.ProjectArchivesMapper;
import com.ruoyi.supervise.mapper.TaskMapper;
import com.ruoyi.supervise.service.IProjectArchivesService;

import cn.hutool.core.date.DatePattern;
import cn.hutool.core.date.DateUtil;

/**
 * @ClassName: ProjectArchivesServiceImpl
 * @Description: 建档项目库serviceimpl
 * @Author wtj
 * @DateTime 2020年3月10日 下午5:13:47
 */
@Service
@DataSource(value = DataSourceType.SLAVE)
public class ProjectArchivesServiceImpl implements IProjectArchivesService 
{
    @Autowired
    private ProjectArchivesMapper projectArchivesMapper;
    
    @Autowired
    private TaskMapper taskMapper;

    /**
     * 查询出建档项目库table数据
     */
	@Override
	public List<ProjectArchives> selectProjectArchivesList(ProjectArchives projectArchives) {
		if(StringUtils.isEmpty(projectArchives.getBeginPubDate()) && !StringUtils.isEmpty(projectArchives.getEndPubDate())) {
			projectArchives.setBeginPubDate("1970-01-01");
		}else if(!StringUtils.isEmpty(projectArchives.getBeginPubDate()) && StringUtils.isEmpty(projectArchives.getEndPubDate())) {
			projectArchives.setEndPubDate(DateUtil.format(new Date(), DatePattern.NORM_DATE_PATTERN));
		}
		return projectArchivesMapper.selectProjectArchivesList(projectArchives);
	}

	@Override
	public int countBaseProjectInfo() {
		// TODO Auto-generated method stub
		return taskMapper.countBaseProjectInfo();
	}

	@Override
	public List<ProjectArchives> selectBaseProjectInfoTop(Integer num) {
		// TODO Auto-generated method stub
		return projectArchivesMapper.selectBaseProjectInfoTop(num);
	}

	@Override
	public List<ProjectArchives> selectBaseProjectInfoAll() {
		// TODO Auto-generated method stub
		return projectArchivesMapper.selectBaseProjectInfoAll();
	}

    
}
